package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JDBCDemo10 {
    public static void main(String[] args) {
        try (Connection con=DBUtil.getConnection()){
            String sql="UPDATE userinfo "+
                    "SET password=?,nickname=?,age=? "+
                    "WHERE id=?";
            PreparedStatement ps=con.prepareStatement(sql);
            ps.setString(1,"666666");
            ps.setString(2,"阿三");
            ps.setInt(3,18);
            ps.setInt(4,2);
            int num=ps.executeUpdate();
            System.out.println(num>0?"修改成功":"修改失败");

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
